home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / Snippets / Networking / Get LAP Connection / GetCurrentLapConnection.c
Encoding:
C/C++ Source or Header  |  1992-07-15  |  2.5 KB  |  101 lines  |  [TEXT/MPS ]

  1. /*
  2.     Sample code to demonstrate use of the LAP Manager call to determine
  3.     the current connection type i.e LocalTalk, EtherTalk phase 1/2, or
  4.     TokenTalk phase 2.
  5.     Rich Kubota 
  6.     DTS
  7.     
  8.     Requires the following Assembler glue routine to make the LAP Manager call
  9. ;*******************
  10. ;File: CallLAPMgr.a
  11. ;*******************
  12. ; C prototype 
  13. ; pascal long CallLAPMgr(short selector);
  14. ; Pascal prototype
  15. ; Function CallLAPMgr(selector : integer): longint;
  16. *******************
  17. LAPMgrPtr   EQU         $B18           ; This points to our start (???ATalkHk2?)
  18. LAPMgrCall  EQU         2             ; Offset to make LAP manager calls
  19.  
  20. CallLAPMgr    PROC    EXPORT
  21.         LINK        A6,#0            ; set up stack frame
  22.         MOVE.W        8(A6),D0        ; move selector parameter into D0
  23.         MOVE.L        A2,-(A7)        ; store A2 on stack
  24.         MOVEA.L        LAPMgrPtr,A2    ; Set A2 to address of LAP Mgr.
  25.         JSR            LAPMgrCall(A2)    ; Call LAP Manager
  26.         MOVE.L        D1,$A(A6)        ; Place result onto stack
  27.         MOVE.L        (A7)+,A2        ; Restore A2
  28.         UNLK        A6                ; restore stack frame
  29.         MOVEA.L        (A7)+,A0        ; put return address into A0
  30.         ADDQ.W        #$2,A7            ; clear off the parameter
  31.         JMP            (A0)            ; return to caller
  32.         RTS
  33.         ENDP
  34.         
  35.         END
  36. ;*******************
  37. ;End of file
  38. ;*******************
  39.  
  40. *******************
  41. Make Instructions
  42. *******************
  43. Asm -case off CallLAPMgr.a
  44. C -r  'GetCurrentLAPConnection.c'
  45. Link -d -c 'MPS ' -t MPST ∂
  46.     CallLAPMgr.a.o GetCurrentLAPConnection.c.o ∂
  47.     "{CLibraries}"StdClib.o ∂
  48.     "{Libraries}"Stubs.o ∂
  49.     "{Libraries}"Runtime.o ∂
  50.     "{Libraries}"Interface.o ∂
  51.     -o GetADEVType
  52. *******************
  53.     end of comments
  54. *******************
  55. */
  56. #include <Types.h>
  57. #include <stdio.h>
  58.  
  59. #define LGetATalkInfo  0x09   /* Get AppleTalk info */
  60.  
  61. /* 'atlk' resource ID's of Apple supplied driver software. */
  62. #define    LTalk        0
  63. #define    ETalkPh1    2
  64. #define    TTalkPh2    5
  65. #define    ETalkPh2    10
  66.  
  67. pascal long CallLAPMgr( short selector);
  68.  
  69. main()
  70. {
  71.     long    result;
  72.     char    adevType;
  73.     char    slot;
  74.     
  75.     result = CallLAPMgr(LGetATalkInfo); 
  76.     adevType = result & 0x000000FF;  /* atlk resource id is return in LSB */
  77.     slot = result>>24;                 /* card slot returned in MSB */
  78.     
  79.     switch (adevType) {
  80.         case LTalk:
  81.                 printf("LocalTalk is the current connection.");
  82.                 break;
  83.         case ETalkPh1:
  84.                 printf("EtherTalk phase 1 is the current connection in slot ");
  85.                 break;
  86.         case ETalkPh2:
  87.                 printf("EtherTalk phase 2 is the current connection in slot ");
  88.                 break;
  89.         case TTalkPh2:
  90.                 printf("TokenTalk is the current connection in slot ");
  91.                 break;
  92.         default:
  93.                 printf("Unrecognized connection in slot ");
  94.                 break;
  95.         }
  96.     if (slot == 0)
  97.         printf("\n");
  98.     else
  99.         printf("%d.\n", slot);
  100. }
  101.